home *** CD-ROM | disk | FTP | other *** search
/ Electro GIG / Electro GIG.iso / gig / demo.ins next >
Text File  |  1995-07-24  |  3KB  |  145 lines

  1. #!/bin/csh -f 
  2. #
  3. #
  4. # -c do not cd to home directory
  5. # -n do -not rewind, extract next file
  6. # -f specify filename for tar command
  7. #
  8. # if the file demo.tar exists in the current directory then nr_tape
  9. # is set to this file. 
  10. # A check is made wether nr_tape is a plain file, if it is no rewinding will
  11. # be done.
  12.  
  13. # make sure path contains necessary directories
  14. set path = (/usr/bin /usr/ucb /bin /usr/bsd /etc /usr/etc $path)
  15. rehash 
  16.  
  17. # check if user is root
  18. set id_line = `id | fgrep 'root'`
  19. if (! $status) then
  20.   echo do not run this script as root
  21.   exit 1
  22. endif
  23.  
  24. set do_not_rewind=0
  25. set do_cd_home=1
  26. set position = 2    # default position is after second tapemarker
  27.  
  28. # which machine is this script running on
  29. set MACHINE = `uname -m`
  30. switch ($MACHINE)
  31.   case IP[0-9]:
  32.   case IP[0-9][0-9]:
  33.   case IP[0-9][0-9][0-9]:
  34.     set machine = 'iris'
  35.     breaksw;
  36.   case 'sun':
  37.   case 'sun4':
  38.   case 'sun4[a-z0-9]':
  39.     set machine = 'sun4'
  40.     breaksw;
  41.   case 9000/7[0-9][0-9]:
  42.     set machine = 'hp'
  43.     breaksw;
  44.   case 'MIPS':
  45.   case 'RISC':
  46.     set machine = 'dec'
  47.     breaksw;
  48.   default:
  49.     set probl_no = 2
  50.     goto problem
  51. endsw
  52.  
  53. set nr_tape = ""
  54. set cd_file = "$0"
  55. set cd_file = $cd_file:r
  56. set cd_file = "$cd_file".tar
  57.  
  58. switch ($machine)
  59.   case 'iris'
  60.     set nr_tape = "/dev/nrtape"
  61.     breaksw;
  62.   case 'sun4':
  63.     set nr_tape = "/dev/nrst0"
  64.     breaksw;
  65.   case 'hp':
  66.     set nr_tape = "/dev/rmt/0mn"
  67.     breaksw;
  68.   case 'dec':
  69.     set nr_tape = "/dev/nrmt0h"
  70.     breaksw;
  71.   default:
  72.     set probl_no = 2
  73.     goto problem
  74. endsw
  75.  
  76. if ( -e $cd_file ) then
  77.   set nr_tape = $cd_file
  78. endif
  79.  
  80. # command line parsing
  81.   set arguments = `getopt cnp:f: $*`
  82.   if ( $status != 0 ) then
  83.     echo "usage: demo.ins [-f filename]"
  84.     exit 2
  85.   endif
  86.   foreach i ( $arguments )
  87.     switch ( $i ) 
  88.       case '-c':
  89.         set do_cd_home = 0 
  90.         breaksw
  91.       case '-n':
  92.         set do_not_rewind = 1 
  93.         breaksw
  94.       case '-p':
  95.         set position = $arguments[2]
  96.         shift arguments
  97.         breaksw
  98.       case '-f':
  99.         set nr_tape=$arguments[2]
  100.         shift arguments
  101.         breaksw
  102.       case '--':
  103.        break
  104.     endsw
  105.     shift arguments
  106.   end
  107.  
  108.  
  109. set MT = "mt -t $nr_tape"
  110.  
  111. if ( -f $nr_tape ) then # check wether nrtape is a normal file
  112.   set do_not_rewind = 2 
  113. endif
  114.  
  115. if ( $do_cd_home) then
  116.   cd $HOME
  117. endif
  118.  
  119. if ($do_not_rewind == 0) then
  120.   $MT rewind
  121.   $MT fsf $position
  122. endif
  123. if (($do_not_rewind == 1) && ($machine == dec)) then
  124.   # skip tapemarker 
  125.   $MT fsf 1
  126. endif
  127. #echo extracting demo files from $nr_tape cwd: $cwd
  128.  
  129. tar xovf $nr_tape
  130. # decompress compressed files
  131. echo decompressing:
  132. find . -type f -name "*.Z" -print -exec compress -fd {} \;
  133.  
  134. if ($do_not_rewind == 0) then
  135.   $MT rewind
  136. endif
  137.  
  138. exit 0;
  139.  
  140. problem:
  141.    echo problem nr $probl_no
  142.  
  143. exit $probl_no
  144. #-----------------------------
  145.